public class CountSort {
    /**
     *
     * @param array
     */
    public static void sort(int[] array) {
        int length = array.length;
        int min = 0, max = 0;
        for (int i = 0; i < length; i++) {
            if (min >= array[i]) {
                min = array[i];
            }
            if (max <= array[i]) {
                max = array[i];
            }
        }
        int d = max - min + 1;
        int[] tem_array = new int[d];
        for (int j : array) {
            tem_array[j - min]++;
        }
        for (int h = 0; h < length; h++) {
            for (int k = 0; k < tem_array[h]; k++) {
                System.out.print(h+min);
            }
        }
    }

    public static void main(String[] args) {
        int[] array={9,8,6,3,2,1,7,4,0,5};
        sort(array);

    }
}
